
/*********************
 *      INCLUDES
 *********************/
#include <stdio.h>
#include <stdlib.h>
#include "main_desktop.h"


LV_FONT_DECLARE(font_32_ganggang)
LV_FONT_DECLARE(font_24_menu_btn)
LV_FONT_DECLARE(font_16_menu_btn)

static void btn_setting_cb(lv_event_t *e)
{
    if(e->code == LV_EVENT_CLICKED)
    {
        lv_app_anim_out_all(lv_scr_act(), 0);
        create_setting_desktop();
    }
}

static void create_window(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_radius(&style, 0);
    lv_style_set_bg_color(&style, lv_color_hex(0xffffff));
    lv_style_set_border_width(&style, 2);
    lv_style_set_border_color(&style, lv_color_hex(0x000000));

    lv_style_set_pad_top(&style, 2);
    lv_style_set_pad_bottom(&style, 2);
    lv_style_set_pad_left(&style, 2);
    lv_style_set_pad_right(&style, 2);

    lv_obj_t* bar = lv_bar_create(lv_scr_act());
    lv_bar_set_range(bar, 0, 100);
    lv_obj_add_style(bar, &style, LV_STATE_DEFAULT);
    lv_obj_set_size(bar, 18, 200);
    lv_obj_align(bar, LV_ALIGN_LEFT_MID, 20, 0);

    lv_obj_set_style_radius(bar, 0, LV_PART_INDICATOR);
    lv_obj_set_style_bg_color(bar, lv_color_hex(0x00ff00), LV_PART_INDICATOR);
    lv_bar_set_value(bar, 60, LV_ANIM_OFF);

    lv_obj_t *title = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(title, &font_32_ganggang, LV_STATE_DEFAULT);
    lv_label_set_text(title, "罡罡冰壶");
    lv_obj_set_style_text_color(title, lv_color_hex(0xff0000), LV_STATE_DEFAULT);
    lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 20);

    lv_obj_t *SN = lv_label_create(lv_scr_act());
    lv_obj_set_style_text_font(SN, &lv_font_montserrat_16, LV_STATE_DEFAULT);
    lv_label_set_text(SN, "SN:2023gd001");
    lv_obj_center(SN);

    lv_obj_t *btn_setting = lv_btn_create(lv_scr_act());
	lv_obj_set_size(btn_setting, 60, 20);
	lv_obj_set_style_radius(btn_setting, 0, LV_PART_MAIN);
	lv_obj_t *label_setting = lv_label_create(btn_setting);
	lv_obj_center(label_setting);
	lv_obj_set_style_text_font(label_setting, &font_16_menu_btn, LV_STATE_DEFAULT);
    lv_label_set_text(label_setting, "设置");
    lv_obj_align(btn_setting,LV_ALIGN_BOTTOM_RIGHT, -40, -20);
    lv_obj_add_event_cb(btn_setting, btn_setting_cb, LV_EVENT_CLICKED, NULL);
}

/*
 *  函数名：  void lv_app_init(void)
 *  输入参数：无
 *  返回值：  无
 *  函数作用：应用初始化入口
*/
void create_main_desktop(void)
{
    create_window();
}


